#!/usr/bin/php -q
<?php

include('/var/www/html/cfg/def.php');
include('/var/www/html/cfg/cfg_host.php');

$message = "";
$stdin = fopen('php://stdin', 'r');
while($line = fgets($stdin)) {
    $message .= "$line";
}
fclose($stdin);

if (($fd= fopen("/var/www/html/logs/access.log", "a"))) {
    fwrite($fd, "$message\n\n-------------------\n");
    fclose($fd);
}

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, ROOT_URL."income.php"); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);

